package com.example.myapplication.AsyncTasks;

import android.os.AsyncTask;
import com.example.myapplication.Note;
import com.example.myapplication.NoteViewFragment;
import com.example.myapplication.RemoteData.RemoteDataJsonHelper;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import java.util.ArrayList;

public class GetJsonTask extends AsyncTask<GetJsonCallBack, Void, Void> {
  private RefreshLayout refreshLayout;
  private NoteViewFragment noteViewFragment;
  GetJsonCallBack getJsonCallBack;
  ArrayList<Note> notes;

  public GetJsonTask(RefreshLayout refreshLayout,NoteViewFragment noteViewFragment) {
    this.refreshLayout = refreshLayout;
    this.noteViewFragment = noteViewFragment;
  }

  @Override protected Void doInBackground(GetJsonCallBack... params) {
    getJsonCallBack = params[0];
    RemoteDataJsonHelper remoteDataJsonHelper = new RemoteDataJsonHelper();
    //remoteDataJsonHelper.DownLoadDataFromServer(getJsonCallBack);
    remoteDataJsonHelper.DownLoadDataFromServer(getJsonCallBack);
    return null;
  }

  @Override protected void onPostExecute(Void unused) {
    refreshLayout.autoRefresh();
    //noteViewFragment.UpdateNoteData();
    //if (getJsonCallBack != null&&notes!=null) {
    //  getJsonCallBack.OnGetFinished(notes);
    //}
  }
}
